package com.ygqh.baby.service;

import java.io.UnsupportedEncodingException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.JsonResult;
import com.foxinmy.weixin4j.model.MediaItem;
import com.foxinmy.weixin4j.model.MediaUploadResult;
import com.foxinmy.weixin4j.model.Pageable;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.mp.message.NotifyMessage;
import com.foxinmy.weixin4j.mp.model.Following;
import com.foxinmy.weixin4j.mp.model.Menu;
import com.foxinmy.weixin4j.mp.model.OauthToken;
import com.foxinmy.weixin4j.mp.model.User;
import com.foxinmy.weixin4j.token.TokenHolder;
import com.foxinmy.weixin4j.tuple.MassTuple;
import com.foxinmy.weixin4j.type.MediaType;
import com.foxinmy.weixin4j.type.TicketType;
import com.ygqh.baby.ao.FileType;
import com.ygqh.baby.model.WxJsapiSignature;
import com.ygqh.baby.model.wx.WxButton;

public interface WxMpAuthorityService {
	/**
	 * 获取自定义的验证标记
	 * 
	 * @return
	 */
	String findCustomToken();

	/**
	 * 获取公众号票据
	 * 
	 * @return
	 */
	TokenHolder findTokenHolder();

	TokenHolder findTokenHolder(String platformNo);

	/**
	 * 外放链接时，加登录认证，http的url则进行短连接处理
	 * 
	 * @param redirectUrl
	 * @return
	 */
	String wxAuth2UrlFormat(String redirectUrl);

	/**
	 * 公众号号菜单发布
	 * 
	 * @param menuJson
	 * @throws WeixinException
	 */
	void publishCustomMenu(List<WxButton> listMenus) throws WeixinException;

	/**
	 * 获取公众号所有菜单
	 * 
	 * @param menuJson
	 * @throws WeixinException
	 */
	@Deprecated
	List<Menu> getAllMenu() throws WeixinException;

	List<Menu> getAllMenu(String platformNo) throws WeixinException;

	/**
	 * 删除公众号菜单
	 * 
	 * @throws WeixinException
	 * 
	 */
	void deleteCustomMenu() throws WeixinException;

	/**
	 * 生成票据
	 * 
	 * @param ticketType
	 * @return
	 * @throws WeixinException
	 */
	Token findTicket(TicketType ticketType) throws WeixinException;

	/**
	 * 生成jsapi签名
	 * 
	 * @param url
	 * @return
	 * @throws WeixinException
	 */
	WxJsapiSignature generateJsapiSignature(String url) throws WeixinException;

	/**
	 * 获取code授权路径
	 * 
	 * @return
	 * @throws WeixinException
	 * @throws UnsupportedEncodingException
	 */
	String getAuthorizeURL(String state, String scopes, String redirectUri) throws WeixinException;

	/**
	 * 获取登录人的授权信息（scope为snsapi_userinfo ）
	 * 
	 * @param code
	 * @return
	 * @throws WeixinException
	 */
	User findUserInfo(String code) throws WeixinException;

	/**
	 * 获取OauthToken（scope为snsapi_base ）
	 * 
	 * @param code
	 * @return
	 * @throws WeixinException
	 */
	OauthToken findOauthToken(String code) throws WeixinException;

	/**
	 * 获取登录人的信息(需关注公众号)
	 * 
	 * @param openId
	 * @return
	 * @throws WeixinException
	 */
	User getUserInfo(String openId) throws WeixinException;

	/**
	 * 获取永久二维码路径二维码
	 * 
	 * @param sourceCode
	 * @return
	 * @throws WeixinException
	 */
	String findQrCodeUrl(String sourceCode) throws WeixinException;

	/**
	 * 获取临时二维码路径二维码
	 * @param sourceCode
	 * @param expireSeconds
	 * @return
	 * @throws WeixinException
	 */
	String findTempQrCodeUrl(String sourceCode, int expireSeconds) throws WeixinException;

	/**
	 * 获取二维码
	 * 
	 * @param path
	 *            跳转路径
	 * @param fileType
	 *            文件类型
	 * @return
	 */
	String getQrCodeUrl(String url, HttpServletRequest request, FileType fileType);

	/**
	 * 获取短连接
	 * 
	 * @param url
	 * @return
	 * @throws WeixinException
	 */
	String getShortUrl(String url);

	/**
	 * 
	 * 获取全部的媒体素材
	 * 
	 * @param mediaType
	 *            媒体类型
	 * @return 素材列表
	 * @see {@link #listMaterialMedia(MediaType, Pageable)}
	 * @throws WeixinException
	 */
	List<MediaItem> getAllMaterialMedia(MediaType mediaType) throws WeixinException;

	User getUserInfo(String openId, String platformNo) throws WeixinException;

	/**
	 * * 发送客服消息(在48小时内不限制发送次数)
	 * 
	 * @param notify
	 *            客服消息对象
	 * @return 处理结果
	 * @see {@link #sendNotify(NotifyMessage, String)}
	 * @throws WeixinException
	 */

	JsonResult sendKeFuMsg(NotifyMessage notify) throws WeixinException;

	List<User> getUsers(String[] openIds) throws WeixinException;

	void addKFAccount();

	// 创建微信公账号菜单
	@Deprecated
	void publishCustomMenu(String menuJson) throws WeixinException;

	void publishCustomMenu(String menuJson, String platformNo) throws WeixinException;

	Following findUserList(String nextOpenId) throws WeixinException;

	List<User> findAllFollowing() throws WeixinException;
	
	List<String> findAllOpenIds() throws WeixinException;

	int getGroupId(String groupName) throws WeixinException;

	void sendAllMsg(MassTuple tuple, boolean isToAll, int groupId) throws WeixinException;


	/**
	 * 新增其他类型永久素材
	 */
	MediaUploadResult addMaterial();
}
